package com.share.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.share.mapper.OrderMapper;
import com.share.pojo.domain.Order;
import com.share.pojo.domain.OrderBill;
import com.share.mapper.OrderBillMapper;
import com.share.pojo.vo.BillDetail;
import com.share.result.JSONResult;
import com.share.service.IOrderBillService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * 订单账单表 服务实现类
 * </p>
 *
 * @author zcj
 * @since 2025-04-12
 */
@Service
public class OrderBillServiceImpl extends ServiceImpl<OrderBillMapper, OrderBill> implements IOrderBillService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public JSONResult detail(String orderNo) {
        BillDetail billDetail = new BillDetail();
        Order order = orderMapper.selectOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, orderNo));
        OrderBill one = super.getOne(new LambdaQueryWrapper<OrderBill>().eq(OrderBill::getOrderNo, orderNo));
        BeanUtils.copyProperties(order,billDetail);
        billDetail.setRealMileage(order.getExpectsMileage());
        BeanUtils.copyProperties(one,billDetail);
        return JSONResult.success(billDetail);
    }
}
